package com.gaga.metadata.utils;

/**
 * 处理sql拼接的问题
 *
 * @author liujia
 * @version 1.0
 * @date 2023/1/14 23:37
 */
public class SqlStrUtils {

    public static String replaceSql(String sql) {
        return sql.replace('\r', ' ')
                .replace('\n', ' ')
                .replaceAll(" {2,}+", " ")
                .replaceAll(" ' ", "'")
                .replaceAll("'and", "' and")
                .replaceAll("'group", "' group");
    }


    public static void main(String[] args) {

        String sql = "DATE_FORMAT\n(\n'\nyyy-mm-dd\n'\n,\n";

        System.out.println(replaceSql(sql));

    }

}
